import { get, post } from '@/request'; 
import type { RecommendUser, FriendRequest ,UserDto} from './types';

// 获取我的好友列表
export const getMyFriends = (userId: number): Promise<UserDto[]> => {
  return get(`/social/myFriends/${userId}`)
  .then(response => response.data);
}

// 获取推荐列表
export const getRecommendations = (
  limit: number = 10,
  userId: number
): Promise<RecommendUser[]> => {
  return get(`/social/recommendations/${userId}`, { params: { limit } })
  .then(response => response.data);
};

// 发送好友请求
export const sendFriendRequest = (toUserId: number, fromUserId: number): Promise<void> => {
  return post(`/social/friend-request`, { toUserId, fromUserId });
};

// 获取好友请求列表
export const getFriendRequests = (userId: number): Promise<FriendRequest[]> => {
  return get(`/social/friend-requests/${userId}`);
};

// 响应好友请求
export const respondToFriendRequest = (
  requestId: number, 
  accept: boolean,
  userId: number
): Promise<void> => {
  return post(
    `/social/friend-request/${requestId}/respond/${userId}`,
    { accept }
  );
};